package com.nineclock.message.listener;

import com.nineclock.message.pojo.NcMessage;
import com.nineclock.message.service.NcMessageService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = "messagePushTopic", consumerGroup = "consumerGroup") //指定监听的topic
@Slf4j
public class MsgConsumerListener implements RocketMQListener<NcMessage> {

    @Autowired
    private NcMessageService messageService;

    @Override
    public void onMessage(NcMessage ncMessage) {
        log.info("接受到消息, 消息 : "+ncMessage);
        messageService.pushMessage(ncMessage);
    }

}